% Reads in an edi file
% latest date 17.4.3

function[tf1] = readedi(fname);

if nargin < 1,
    fname = '*.edi';
else,
    fname = [fname '*.edi'];
end;

ProcDef1.equations=[4 1 2;5 2 1];
ProcDef1.neq = 2;
ProcDef1.rreqn = [4 1 2 6 7;5 2 1 7 6];

[file,path] = uigetfile(fname, 'Open EDI file');

if file == 0,
K = 2;
return;
end;
line1 = [path file];
fid = fopen(line1,'rt'); 

[SPM,er]=edi_in(fid);

ProcDef1.nfrq=length(SPM.spectra);
ProcDef1.TLFreq1=SPM.head.frq; 
ProcDef1.file1=file;
nchan = length(SPM.spectra(1).data);
tf1 = TransFn(SPM,ProcDef1);

file11 = file;
%%%%

ProcDef2.equations=[4 1 2;5 2 1];
ProcDef2.neq = 2;
ProcDef2.rreqn = [4 1 2 6 7;5 2 1 7 6];

[file,path] = uigetfile(fname, 'Open second EDI file');

if file == 0,
K = 2;
return;
end;
line1 = [path file];
fid = fopen(line1,'rt'); 

[SPM,er]=edi_in(fid);

ProcDef2.nfrq=length(SPM.spectra);
ProcDef2.TLFreq1=SPM.head.frq; 
ProcDef2.file1=file;
nchan = length(SPM.spectra(1).data);
tf2 = TransFn(SPM,ProcDef2);
figure(1);

cmpresph(tf1,ProcDef1,tf2,ProcDef2);

file22 = file;

legend(file11,file22);